<?php

class Titik_jalan_model extends arfaModel{

	function __construct(){
		parent::__construct();
		$this->table_name	= "titik_jalan";
		$this->primary_key	= "ID_TITIK_JALAN";
		$this->order_by		= "ID_TITIK_JALAN ASC"; 
	}
	
	function get_rute($id)
	{
		$this->db->select("*");
		$this->db->from($this->table_name);
		$this->db->where("ID_RUAS",$id);
		$query = $this->db->get();
		
		return $query->result_array();
	}
	
	function get_titik()
	{
		$this->db->select("*");
		$this->db->from($this->table_name);
		$this->db->where("LATITUDE !=",0);
		$query = $this->db->get();
		
		return $query->result_array();
	}
	
	function get_paktif()
	{
		$query = $this->db->query("
			SELECT
			titik_jalan.ID_TITIK_JALAN,
			titik_jalan.ID_RUAS,
			titik_jalan.LATITUDE,
			titik_jalan.LONGTITUDE,
			ruas_jalan.ID_RUAS,
			ruas_jalan.ID_PERIODE,
			master_periode.ID_PERIODE,
			master_periode.STATUS_PERIODE
			FROM titik_jalan
			JOIN ruas_jalan ruas_jalan ON titik_jalan.ID_RUAS = ruas_jalan.ID_RUAS
			JOIN master_periode master_periode ON ruas_jalan.ID_PERIODE = master_periode.ID_PERIODE
			WHERE master_periode.STATUS_PERIODE = 1
		");
		
		return $query->result_array();
	}
}